1   /*
2    * Copyright (C) 2011 The Guava Authors
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.google.common.util.concurrent;
18  
19  import com.google.common.annotations.GwtCompatible;
20  
21  import javax.annotation.Nullable;
22  
23  /**
24   * {@link Error} variant of {@link java.util.concurrent.ExecutionException}. As
25   * with {@code ExecutionException}, the error's {@linkplain #getCause() cause}
26   * comes from a failed task, possibly run in another thread. That cause should
27   * itself be an {@code Error}; if not, use {@code ExecutionException} or {@link
28   * UncheckedExecutionException}. This allows the client code to continue to
29   * distinguish between exceptions and errors, even when they come from other
30   * threads.
31   *
32   * @author Chris Povirk
33   * @since 10.0
34   */
35  @GwtCompatible
36  public class ExecutionError extends Error {
37    /**
38     * Creates a new instance with {@code null} as its detail message.
39     */
40    protected ExecutionError() {}
41  
42    /**
43     * Creates a new instance with the given detail message.
44     */
45    protected ExecutionError(@Nullable String message) {
46      super(message);
47    }
48  
49    /**
50     * Creates a new instance with the given detail message and cause.
51     */
52    public ExecutionError(@Nullable String message, @Nullable Error cause) {
53      super(message, cause);
54    }
55  
56    /**
57     * Creates a new instance with the given cause.
58     */
59    public ExecutionError(@Nullable Error cause) {
60      super(cause);
61    }
62  
63    private static final long serialVersionUID = 0;
64  }